package com.wyix.coffee.service;

import com.wyix.coffee.bean.CoffeeMaker;

/**
 * @author wangdx
 * @since 2025/8/6
 */
public class BaristaConstructorInjection {
    private final CoffeeMaker coffeeMaker; // 不可变依赖

    // 构造器注入（强制依赖）
    public BaristaConstructorInjection(CoffeeMaker coffeeMaker) {
        if (coffeeMaker == null) {
            throw new IllegalArgumentException("咖啡机不能为空！");
        }
        this.coffeeMaker = coffeeMaker;
    }

    public String serveCoffee() {
        return "咖啡师（构造注入）服务：" + coffeeMaker.makeCoffee();
    }
}